package com.example.testproject.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.testproject.R
import com.example.testproject.bean.TopicSecondBean
import kotlinx.android.synthetic.main.topic_details_item.view.*
import kotlinx.android.synthetic.main.topic_details_item_child.view.*

/**
 *
 * @ClassName: TopicDetailsAdapter
 * @Author: android 超级兵
 * @CreateDate: 10/28/21$ 12:50 PM$
 * TODO
 */
class TopicDetailsAdapter(data: List<TopicSecondBean>) :
    BaseQuickAdapter<TopicSecondBean, BaseViewHolder>(
        R.layout.topic_details_item_child,
        data
    ) {
    override fun convert(helper: BaseViewHolder, item: TopicSecondBean) {

        helper.itemView.tvTopicDetails.text = String.format("${item.seq}")

        // 检测选项中是否有选中的。。
        var tempCheck = false
        item.child.forEach {
            if (it.isSelect) {
                tempCheck = true
            }
        }
        helper.itemView.tvTopicDetails.background =
            if (tempCheck) mContext.resources.getDrawable(R.drawable.topic_details_green) else
                mContext.resources.getDrawable(R.drawable.topic_details_red)
    }
}